<template>
	<div class="">
		<div class="height45">
			<header class="top_bar">
				<a onclick="window.history.go(-1)" class="icon_back"></a>
				<h3 class="cartname">提取现金</h3>
			</header>
		</div>
		<div class="" style="margin: 20px;">
			<div class="background_fff">
				<!--<div class="line_height60 background_f0 padding_lf10_rg10 font_size16">
					银行卡号：{{bankInfo[0].BankCard}}
				</div>-->
				<div class="position_rel" style="padding: 30px 20px;padding-bottom: 100px;">
					<div class="line_height2 overflow_hidden">
						<div class="fl font_size16">
							提现金额
						</div>
						<div class="fr">
							<span class="color666">可提现金额</span>
							<span class="color_main_red">{{uInfs.Balance}}</span>
							<span>元</span>
						</div>
					</div>
					<div class="border_bot_dcdcdc line_height60 font_size22">
						￥<input v-model="money" type="number" />
					</div>
					<!--<div class="color666 line_height2">
						注：提现实际到账扣除{{charge}}%的手续费
					</div>-->
					<div @click="TiXian()" class="btn_bot">
						申请提现
					</div>
				</div>
			</div>
		</div>
	</div>
</template>
<script>
	import { Toast } from 'mint-ui';
	export default {
		data() {
			return {
				money: '',
				charge: '',
				bankInfo: [0],
				remain: '',
				uInfs: '',
				btnClick: false,
			}
		},
		mounted() {
			let _this = this;
			_this.getUDatas()
			_this.GetBankInfo()
			_this.GetCharge()
		},
		methods: {
			TiXian() {
				let _this = this;
				if(!_this.btnClick) {
					Toast('请先填写提现账号信息！')
					return false;
				}
				_this.$http.post('/client/Cashes', {
					BankId: _this.bankInfo[0].Id,
					Money: _this.money
				}, localStorage.Authorization, res => {
					console.log('提现res', res)
					if(res.code === 200) {
						Toast(res.data);
						setTimeout(function() {
							_this.$router.go(-1)
						}, 1500)
					} else {
						Toast(res.error);
					}
				})
			},
			getUDatas() {
				let _this = this;
				_this.$http.get('/client/Members', null, localStorage.Authorization, res => {
					console.log('我的账户res', res)
					if(res.code === 200) {
						if(res.data.dataCount > 0) {
							_this.uInfs = res.data.list[0];
						} else {
							_this.uInfs.Balance = 0;
							_this.uInfs.Points = 0;
						}
					} else if(res.code === 101) {
						localStorage.fromPath = _this.$route.fullPath
						_this.$router.push({
							path: '/wx/login'
						})
					}
				})
			},
			GetBankInfo() {
				let _this = this
				_this.$http.get('/client/Banks', null, localStorage.Authorization, res => {
					if(res.code === 200) {
						console.log('银行卡信息res', res)
						if(res.data.dataCount!=0) {
							_this.bankInfo = res.data.list
							_this.btnClick = true
						} else {
							_this.btnClick = false
						}

					}
				})
			},
			GetCharge() {
				let _this = this
				_this.$http.get('/front/Charge', null, localStorage.Authorization, res => {
					console.log('提现费率res', res)
					if(res.code === 200) {
						_this.charge = res.data
					}
				})
			}
		}
	}
</script>
<style>
	@import '../assets/css/login.css';
</style>
<style scoped="scoped">
	.height45 {
		height: 45px;
	}
	
	.get_code_btn {
		position: absolute;
		top: 10px;
		right: 20px;
		border: 1px solid red;
		border-radius: 4px;
		padding: 5px 8px;
		color: red;
	}
	
	.go_reg_box xieyi {
		display: inline-block;
		color: #aaa;
		height: 20px;
		line-height: 20px;
		margin-top: 10px;
	}
	
	.background_f0 {
		background: #f0f0f0;
	}
</style>